import subprocess
# 批量pip uninstall 所有的第三方包  根据requirements.txt
with open("requirements.txt", "r", encoding="utf-16") as f:
    packages = [line.split("==")[0].strip() for line in f]

for package in packages:
    try:
        subprocess.run(["pip", "uninstall", "-y", package], check=True)
        print(f"Successfully uninstalled: {package}")
    except subprocess.CalledProcessError as e:
        print(f"Failed to uninstall {package}: {e}")